$(document).ready(function () {
function_01();
$("#btn_submit").click(function_02);
});
//page load時 會自動觸發
var function_01 = function () {
//do something
};
//$("#id").click時觸發
var function_02 = function () {
//do something
};
延伸閱讀:常用的jQuery事件觸發使用↓↓↓↓↓↓↓
http://www.w3school.com.cn/jquery/jquery_ref_events.asp
2018-12-26 $(document).ready(function () { ... }); == $(function () { ... });
$(document).ready(function () {
var $targetObj = $('#targetObj');
//初始化設定
cat.touchjs.init($targetObj, function (left, top, scale, rotate) {
//...
});
//初始化拖動手勢
cat.touchjs.drag($targetObj, function (left, top) {
//...
});
//初始化縮放手勢
cat.touchjs.scale($targetObj, function (scale) {
//...
});
//初始化旋轉手勢
cat.touchjs.rotate($targetObj, function (rotate) {
//...
});
});
//--------------------------------------
$(function () {
var $targetObj = $('#targetObj');
//初始化设置
cat.touchjs.init($targetObj, function (left, top, scale, rotate) {
//...
});
//初始化拖動手勢
cat.touchjs.drag($targetObj, function (left, top) {
//...
});
//初始化縮放手勢
cat.touchjs.scale($targetObj, function (scale) {
//...
});
//初始化旋轉手勢
cat.touchjs.rotate($targetObj, function (rotate) {
//...
});
});